package com.atguigu.guli.service.edu.controller;


import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.Teacher;
import com.atguigu.guli.service.edu.feign.OssFileService;
import com.atguigu.guli.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 * 讲师 前端控制器
 * </p>
 *
 * @author yz
 * @since 2022-07-18
 */
@Api(tags = "讲师模块")
@RestController
@RequestMapping("/edu/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private OssFileService ossFileService;

    //查询所有讲师
    @GetMapping("/findAll")
    public List<Teacher> findAll() {
        return teacherService.list();
    }
    //根据id查询讲师
    @GetMapping("/findById/{id}")
    public Teacher findById(@PathVariable("id") String id){
        return teacherService.getById(id);
    }
    @ApiOperation("测试服务调用")
    @GetMapping("/test")
    public R test(){
        ossFileService.test();
        return R.ok();
    }

    //测试springsession
    @GetMapping("/set")
    public R set(HttpSession session){
        session.setAttribute("k","hehehehhe..........");
        return R.ok();
    }
    @GetMapping("/get")
    public R get(HttpSession session){
        System.out.println(session.getAttribute("k"));

        return R.ok();
    }
}

